import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import "./plugins/element.js";
//导入全局样式
import "./assets/css/global.css";
import "./assets/css/iconfont.css";
//配置axios
import axios from "axios";

import TreeTable from "vue-table-with-tree-grid";
import Dialog from "./components/dialog.vue";
//请求根路径
axios.defaults.baseURL = "/api/";
axios.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
// axios.defaults.baseURL = "http://localhost:21021/api/"
axios.interceptors.request.use((config) => {
    config.headers.Authorization = window.sessionStorage.getItem("token");
    if (window.sessionStorage.getItem("userId")) {
        if (config.url.includes("?"))
            config.url += `&userId=${window.sessionStorage.getItem("userId")}`;
        else config.url += `?userId=${window.sessionStorage.getItem("userId")}`;
    }
    return config;
});
Vue.config.productionTip = false;
//请求方式
Vue.prototype.$http = axios;

Vue.component("tree-table", TreeTable);
Vue.component("dz-dialog", Dialog);

new Vue({
    router,
    render: (h) => h(App),
}).$mount("#app");
